using SearchTools.Search;
using NUnit.Framework;
using LuceneSearch = Lucene.Net.Search;
using System;

namespace SearchTools.Tests
{

	[TestFixture]
	public class Tests
	{
		private void DoSearch(string q)
		{
			Console.Write("Query: " + q.ToString());

			ResultCollection col = Searcher.Search(q);

			Console.WriteLine(string.Format(" returned {0} hits",col.Count));

			for (int i = 0; i < col.Count; i++)
			{
				Console.WriteLine(string.Format("Doc {0} Score {1}",i,col[i].Score));
			}
		}

		[Test]
		public void TestSimpleTermSearch()
		{
			DoSearch("contents:online");

			DoSearch("contents:business");

			DoSearch("contents:council");

			DoSearch("language:en");

			DoSearch("contents:zzzasasxsdzxzcxciii");

			DoSearch("title:[a -> c]");
		}

		[Test]
		public void TestComplexTermSearch()
		{
			DoSearch("contents:onlife");

			DoSearch("contents:onlife~3");

			DoSearch("contents:online && (contents:business~4 || contents:online)^4");

			DoSearch("contents:online && (contents:business~4 || contents:online)^8");

			DoSearch("contents:online && (contents:business~4 || contents:online)^0.2");
		}

		[Test]
		public void TestMetaInjection()
		{
            DoSearch("#injectmeta(MockMember:interest,contents)");
            DoSearch("#injectmeta(MockPage:interest,contents)");
		}

		
	}
}
